<%@ page import="cardbs.domain.Department" %>
<%@ page import="java.util.*" %>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Εισαγωγή εργασίας</title>
<script type="text/javascript">
<!--

function validate_form ( )
{
    valid = true;
	if (document.insertWork.price.value <= 0 )
    {
        alert ("Παρακαλώ δώστε θετική τιμή εργασίας" );
        valid = false;
    }
    if (document.insertWork.description.value =="")
    {
        alert ("Παρακαλώ δώστε την περιγραφή της νέας εργασίας" );
        valid = false;
    }	
    return valid;
}

//-->
</script>
</head>
<body>
<%
HashSet <Department> departments = (HashSet)session.getAttribute("allDepartments");
 %>
 
 <FORM Name = "insertWork" action="/car-dbs-implementation/InsertWorkServlet" onsubmit="return validate_form()" method="post">
 <div align="center">
<jsp:include page="exitPage.jsp"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr>
					<td width="32%"><img
						src="../../images/loginPages/ΕισαγωγήΕργασίας.png" alt="Service A.E."
						width="260" height="228" /></td>
					<td style="width: 206px" width="842">
<h2>Επιλέξτε τμήμα</h2>
 <br>
  <%Iterator itr = departments.iterator();
    while(itr.hasNext()){
      Department d = (Department) itr.next();
      String depName = d.getDepName();
      String depCode = d.getDepCode().toString();
      if(itr.hasNext()==true){%>
      <INPUT TYPE="radio" NAME="departments" VALUE=<%=depCode%> /> <%=depName%><br/>
 	  <BR>
      <%}else{%>
      <INPUT TYPE="radio" NAME="departments" VALUE=<%=depCode%> checked /> <%=depName%><br/>
 	  <BR>      
      	<%}
      }
  %>
  </td>
  </tr>
  </table>
  <table width="40%">
  <tr>
    <td width="12%">
    <td>Περιγραφή εργασίας </td>
    <td><input type="text" name="description"></td>
  </tr>
  <tr>
    <td width="12%">
    <td >Τιμή εργασίας (ευρώ)</td>
    <td><input type="text" name="price"></td>
  </tr>
     <%
		String error = (String)session.getAttribute("errorWorkExists");
		
		if ((error!=null) && (error.equals("true")))
		{
		%>
		<tr>
    		<td></td>
    		<td><font size="4" face="arial" color="red">Η εργασία υπάρχει!!!</font></td>
  		</tr><%
  		session.setAttribute("errorWorkExists","false");
		}%>		
	
  <tr>
    <td>&nbsp;</td>
  </table>
  <table>
  <tr>
  <td width="12%">
  <td width="5%" width="56">
					<input TYPE="submit" VALUE="Εισαγωγή Εργασίας" style="width: 193px">
					</td>
					<td width="5%" width="56">
					<a href="/car-dbs-implementation/uipages/firstPagePages/HeadmasterViewLoginPage.jsp"><img src="../../images/CancelButton.png" style="border:1px solid black;"/></a>
	</td>
</tr>
</table>
</div>
</FORM>

</body>
</html>